﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Text;
using Autofac;
using Autofac.Extensions.DependencyInjection;
using MaximServices;
using MaximServices.Common;
using MaximServices.Data;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;

namespace MaximApp
{
    public class Startup
    {
        public void ConfigureServices(IServiceCollection services)
        {
            var configuration = new ConfigurationBuilder()
                .SetBasePath(Directory.GetCurrentDirectory())
                .AddJsonFile("appsettings.json")
                .Build();

            services.UseIdFactory(configuration);
            services.AddOptions();
            services.Configure<ConnectionStringList>(configuration.GetSection("ConnectionStringList"));

            var builder = new ContainerBuilder();
            builder.Populate(services);
            builder.RegisterModule<CoreModule>();

            var buildContainer = builder.Build();

            ServiceLocator.Instance = buildContainer;

            new AutofacServiceProvider(buildContainer);
        }
    }
}
